package org.rency.common.memcache.repository;

import java.util.List;

import javax.annotation.Resource;

import org.rency.common.memcache.bean.MemcacheNode;
import org.rency.common.memcache.dao.NodeDao;
import org.springframework.beans.factory.InitializingBean;

public class NodeRepositoryImpl implements NodeRepository,InitializingBean {
	
	@Resource(name="nodeDao")
	private NodeDao nodeDao;
	
	@Override
	public List<MemcacheNode> loadAll() {
		return nodeDao.loadAll();
	}

	@Override
	public MemcacheNode load(Integer id) {
		return nodeDao.load(id);
	}

	@Override
	public boolean save(MemcacheNode node) {
		return nodeDao.save(node);
	}

	@Override
	public boolean updateWeight(Integer id, Integer weight) {
		return nodeDao.updateWeight(id, weight);
	}

	@Override
	public boolean delete(Integer id) {
		return nodeDao.delete(id);
	}
	
	@Override
	public void afterPropertiesSet() throws Exception {
		nodeDao.createTable();
	}
	
}